package operation;
import booklist.BookList;
import book.Book;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-10
 * Time: 15:36
 */
public class AddOperation implements Operation {
    @Override
    public void work(BookList booklist) {
        Scanner scan = new Scanner(System.in);
        System.out.println("添加书籍：");
        System.out.println("请输入名称：");
        String name = scan.nextLine();
        System.out.println("请输入作者：");
        String author = scan.nextLine();
        System.out.println("请输入类型：");
        String type = scan.nextLine();
        System.out.println("请输入价格：");
        int price = scan.nextInt();
        Book book = new Book(name,author,price,type);
        //获取当前书架中的下标
        int cursize = booklist.getBooksize();
        //往书架中存放书籍
        booklist.setbook(cursize,book);
        booklist.setBooksize(cursize+1);
        System.out.println("添加成功！");
    }


}
